# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.Forms.V1.Model.Watch do
  @moduledoc """
  A watch for events for a form. When the designated event happens, a notification will be published to the specified target. The notification's attributes will include a `formId` key that has the ID of the watched form and an `eventType` key that has the string of the type. Messages are sent with at-least-once delivery and are only dropped in extraordinary circumstances. Typically all notifications should be reliably delivered within a few seconds; however, in some situations notifications may be delayed. A watch expires seven days after it is created unless it is renewed with watches.renew

  ## Attributes

  *   `createTime` (*type:* `DateTime.t`, *default:* `nil`) - Output only. Timestamp of when this was created.
  *   `errorType` (*type:* `String.t`, *default:* `nil`) - Output only. The most recent error type for an attempted delivery. To begin watching the form again a call can be made to watches.renew which also clears this error information.
  *   `eventType` (*type:* `String.t`, *default:* `nil`) - Required. Which event type to watch for.
  *   `expireTime` (*type:* `DateTime.t`, *default:* `nil`) - Output only. Timestamp for when this will expire. Each watches.renew call resets this to seven days in the future.
  *   `id` (*type:* `String.t`, *default:* `nil`) - Output only. The ID of this watch. See notes on CreateWatchRequest.watch_id.
  *   `state` (*type:* `String.t`, *default:* `nil`) - Output only. The current state of the watch. Additional details about suspended watches can be found by checking the `error_type`.
  *   `target` (*type:* `GoogleApi.Forms.V1.Model.WatchTarget.t`, *default:* `nil`) - Required. Where to send the notification.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :createTime => DateTime.t() | nil,
          :errorType => String.t() | nil,
          :eventType => String.t() | nil,
          :expireTime => DateTime.t() | nil,
          :id => String.t() | nil,
          :state => String.t() | nil,
          :target => GoogleApi.Forms.V1.Model.WatchTarget.t() | nil
        }

  field(:createTime, as: DateTime)
  field(:errorType)
  field(:eventType)
  field(:expireTime, as: DateTime)
  field(:id)
  field(:state)
  field(:target, as: GoogleApi.Forms.V1.Model.WatchTarget)
end

defimpl Poison.Decoder, for: GoogleApi.Forms.V1.Model.Watch do
  def decode(value, options) do
    GoogleApi.Forms.V1.Model.Watch.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.Forms.V1.Model.Watch do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
